﻿using System;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Web;

    public class Translations
    {
        public Top XMLdata;
        public Translations()
        {
            XMLdata = new Top();
        }
        public Translations(String sLangSymbol, Int32 iStage)
        {

            String sStage = String.Empty;
            if (iStage == 1)
                sStage = "../";

            if (sLangSymbol != null)
            {
                try
                {
                    XmlSerializer s = new XmlSerializer(typeof(Top));
                    String filePath = HttpContext.Current.Server.MapPath(sStage + "XML/" + sLangSymbol + ".xml");
                    XmlTextReader r = new XmlTextReader(filePath);
                    XMLdata = (Top)s.Deserialize(r);
                    r.Close();
                }
                catch
                {
                    XmlSerializer s = new XmlSerializer(typeof(Top));
                    String filePath = HttpContext.Current.Server.MapPath("XML/ru.xml");
                    XmlTextReader r = new XmlTextReader(filePath);
                    XMLdata = (Top)s.Deserialize(r);
                    r.Close();
                }
            }
        }
    }


    [XmlRootAttribute("Root", Namespace = "", IsNullable = false)]
    public class Top
    {
        [XmlArrayAttribute("Values")]
        [XmlArrayItemAttribute("Value", typeof(PageData), IsNullable = false)]
        public PageData[] Values;
    }

    [Serializable]
    public class PageData
    {
        [XmlAttribute("key")]
        public string key;
        [XmlAttribute("name")]
        public string name;
    }



